/***********************************************
 * Title:       IbatisSpecialityDao.java
 * Description: TODO ADD DISCRIPTION TO IbatisSpecialityDao.java
 * Author:      LeiKang
 * Create Date: 2009-12-8
 * CopyRight:   CopyRight(c)@2009
 * Version:     1.0
 ***********************************************
 */

package edu.tju.education;

/**
 * @author LeiKang
 *
 */
 
import java.sql.SQLException;
import java.util.List;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.younker.waf.db.IBatisConfig;

import edu.tju.education.ISpecialityDao;
import edu.tju.education.Speciality;

public class IbatisSpecialityDao implements ISpecialityDao
{

        protected SqlMapClient sqlMap = IBatisConfig.getSqlMapInstance();

        /* (non-Javadoc)
         * @see edu.tju.education.ISpecialityDao#deleteSpeciality(long)
         */
        public void deleteSpeciality(long id) throws SQLException
        {
                sqlMap.delete("deleteSpeciality", id);                
        }

        /* (non-Javadoc)
         * @see edu.tju.education.ISpecialityDao#getSpecialityAnd(edu.tju.education.Speciality)
         */
        @SuppressWarnings("unchecked")
		public List<Speciality> getSpecialityAnd(Speciality speciality) throws SQLException
        {
                return sqlMap.queryForList("getSpecialityAnd", speciality);
        }

        /* (non-Javadoc)
         * @see edu.tju.education.ISpecialityDao#getSpecialityById(long)
         */
        public Speciality getSpecialityById(long id) throws SQLException
        {
        	
                return (Speciality) sqlMap.queryForObject("getSpecialityById", id);
        
        }

        /* (non-Javadoc)
         * @see edu.tju.education.ISpecialityDao#getSpecialityOr(edu.tju.education.Speciality)
         */
        @SuppressWarnings("unchecked")
		public List<Speciality> getSpecialityOr(Speciality speciality) throws SQLException
        {
        	
                return sqlMap.queryForList("getSpecialityOr", speciality);
                
        }

        /* (non-Javadoc)
         * @see edu.tju.education.ISpecialityDao#insertSpeciality(edu.tju.education.Speciality)
         */
        public Long insertSpeciality(Speciality speciality) throws SQLException
        {
        	
                return (Long) sqlMap.insert("insertSpeciality",speciality);
                
        }

        /* (non-Javadoc)
         * @see edu.tju.education.ISpecialityDao#updateSpeciality(edu.tju.education.Speciality)
         */
        public int updateSpeciality(Speciality speciality) throws SQLException
        {
        	
                return sqlMap.update("updateSpeciality", speciality);
                
        }

        

}
